package com.kang;

import com.kang.commons.filter.CrossFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @program: photo_fawu
 * @description: 启动类
 * @author: K.faWu
 * @create: 2021-10-25 15:10
 **/
@SpringBootApplication
@EnableJpaRepositories
@EnableDiscoveryClient
@EnableFeignClients //开启 feign模式
@EnableScheduling //定时任务
@MapperScan(basePackages = "com.kang.mapper")
public class PhotoApp {
    public static void main(String[] args) {
        SpringApplication.run(PhotoApp.class,args);
    }

    @Bean
    public FilterRegistrationBean<CrossFilter> crossDomainFilter(){
        FilterRegistrationBean<CrossFilter> registrationBean =
                new FilterRegistrationBean<>();
        //web.xml中的filter
        registrationBean.setFilter(new CrossFilter());

        //web.xml 中的url-pattern
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
